// This example show how can you build two pulses with a delay;
// an infrared and attosecond.

#include <iostream>
#include <complex>
#include<math.h>
#include "timegrid1.h"
#include "timeobject1.h"
#include "laser.h"

#include <sys/types.h>
#include <sys/stat.h>

using namespace std;

int main()
{   	
	FILE *out0, *out1, *out2, *out3, *out4;
	FILE *out5, *out6, *out7, *out8, *out9, *outp; 
	
	out0=fopen("out0.txt","w");
	out1=fopen("out1.txt","w");
	
	out2=fopen("out2.txt","w");
	out3=fopen("out3.txt","w");
	
	out4=fopen("out4.txt","w");
	out5=fopen("out5.txt","w");
	
	/***************************************************************************/
	int npulses= 2;	
	laser fdet(npulses);
	
	double tstart     = 0;               // Start time of the first pulse
	double dt     = 0.05;                // Temporary increase
	double offset = 50.0;                // Time before the pulse atomic unit
	double outset = 50.0e0;	             // Time after the pulse atomic unit

	//First pulse Laser
	fdet.I0[0]      = 10.0e13;  		 // Intensity W/cm^2 
	fdet.e[0]       = 0.5;  			 // Elliptical of the pulse
	fdet.w0[0]      = 0.027;             // Central frequency
   	fdet.cycles0[0] = 6;                 // Cycles number
   	fdet.cep0[0]    = 0.;                // Carrier Envelope Phase
	fdet.phi_rel[0] = 1*pi/2.0;          // Relative phase between the polarization Ex and Ey
	
	double periodIR = dospi/fdet.w0[0];	 //Period
	double periodIRC= periodIR+4.8;	  
	fdet.delay0[0]  = -3*periodIRC/4;    //Delay IR and attosecond			

    //Second pulse Laser	
	fdet.I0[1]      = 1e15;  			 // Intensity W/cm^2              
	fdet.e[1]       = 0;  			     // Elliptical of the pulse
	fdet.w0[1]      = 4;                 // Central frequency (atomic unit)
   	fdet.cycles0[1] = 10;                // Cycles number
   	fdet.cep0[1]    = 0.;  	             // Carrier Envelope phase
	fdet.phi_rel[1] = 0*pi/2.0;          // Relative phase
   	
   	fdet.laser_pulses(dt, tstart,  offset,  outset);
		
	for (int ktime=0; ktime<fdet.g.n; ktime++)
		fprintf(out5,"%e %e %e %e %e\n",fdet.g.t[ktime],fdet.efield.f[ktime][0],fdet.avector.f[ktime][0],
				fdet.efield.f[ktime][1], fdet.avector.f[ktime][1]);
	/***************************************************************************/	
	
		
	fclose(out0);
	fclose(out1);   
	fclose(out2);
	fclose(out3);
}//End main



